package init

import (
	"fmt"
	"github.com/redis/go-redis/v9"
	"video-srv/basic/config"
)

func InitRedis() {
	redisConfig := config.AppCfg.Redis
	Addr := fmt.Sprintf("%s:%d",
		redisConfig.Host, redisConfig.Port,
	)
	config.Rdb = redis.NewClient(&redis.Options{
		Addr:     Addr,
		Password: redisConfig.Password,
		DB:       redisConfig.Database,
	})
	err := config.Rdb.Ping(config.Ctx).Err()
	if err != nil {
		return
	}
	fmt.Println("redis 连接成功")
}
